package homework.api01.apitest02;

import java.util.Random;
import java.util.Scanner;

public class Test02 {
    public static void main(String[] args) {
        String line =
                "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        System.out.println(line.length());
        Random rand = new Random();
        String code = "";
        for (int i=0;i<4;i++){
            int index = rand.nextInt(line.length());
            char c = line.charAt(index);
            code+=c;
        }
        System.out.println("验证码："+code);
        System.out.println("请输入验证码");
        Scanner scan = new Scanner(System.in);
        String input =scan.nextLine();
        if (input.equalsIgnoreCase(code)){
            System.out.println("通过!");
        }else {
            System.out.println("失败!");
        }
    }
}
